import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author Klys
 * @Date 2023/6/17 19:53
 * @Description
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {

        Function<String, Integer> doFunc = Main::getInt;
        Integer apply = doFunc.apply("a");
        System.out.println(apply);

        User user = new User();
        User user1 = null;
        user.setAge(2);
        System.out.println(Objects.equals(user.getName(), "123"));
        User user2 = new User("klys", 20);
        User user3 = new User("klys", 21);
        User user4 = new User("zz", 19);
        List<User> list = new ArrayList<>(Arrays.asList(user2, user3, user4));
        Map<String, User> collect = list.stream().collect(Collectors.toMap(
                u -> u.getName(),
                Function.identity(),
                (u1, u2) -> {
                    u1.setAge(u1.getAge() + u2.getAge());
                    return u1;
                }));
        System.out.println(collect);


        Function<String, String> add = Main::add;
        String s = add.apply("uzi");
        System.out.println(s);


        User user5 = new User("111", 111);
        BiConsumer<User, String> setName = User::setName;
        System.out.println(setName);
        setName.accept(user5, "klys");
        System.out.println(user5);

        /*
         * NAME 1  AGE 2
         * NAME 1  AGE 3
         * NAME 2  AGE 1
         *
         *
         * @Author Klys
         * @Description //TODO
         * @Date
         * @Param
         * @return
         **/
    }

    static Integer getInt(String str) {
        if (str == null) {
            return null;
        }
        if (str == "a") {
            return 1;
        }
        if (str == "b") {
            return 2;
        }
        return 99;
    }

    static String add(String str) {
        return "我是EDG-" + str;
    }
}

class User {
    String name;
    Integer age;

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public User() {
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
